//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _VIEW_H
#define _VIEW_H
#include <QSharedPointer>
#include <QScopedPointer>
#include "viewattributegroup.h"
#include "document.h"
class AttrEvent;
class EventForwarder;
//
class View {
   friend class EventForwarder;
   //constructor,destructor
public:
   View();
   ~View();
   //document get/set methods
public:
   inline const Document *get_document() const;
   inline Document *get_document();
   //attribute group get/set methods
public:
   //inline const ViewAttributeGroup *get_attr_group();
   inline const QSharedPointer<ViewAttributeGroup> &get_attr_group();
   void set_attr_group(const QSharedPointer<ViewAttributeGroup> &group);
   //event handlers
protected:
   virtual void handle_attr_event(AttrEvent *evnt);
   //virtual void handle_set_document();
   virtual void handle_set_attr_group();
   virtual void handle_pre_primitive(const Primitive &prim);
   virtual void handle_post_primitive(const Primitive &prim);
   virtual void handle_fail_primitive(const Primitive &prim);
   virtual void handle_post_primitive_group(const PrimitiveGroup &prim_grp);
   //data
private:
   //QPointer<Document> document;
   QSharedPointer<ViewAttributeGroup> attr_group;
   QScopedPointer<EventForwarder> eventForwarder;
};
//
inline const Document *View::get_document() const {
   //return document;
   if (attr_group)
      return attr_group->get_document();
   return NULL;
}
inline Document *View::get_document() {
   //return document;
   if (attr_group)
      return attr_group->get_document();
   return NULL;
}
/*inline const ViewAttributeGroup *View::get_attr_group() {
   return attr_group.data();
}*/
inline const QSharedPointer<ViewAttributeGroup> &View::get_attr_group() {
   return attr_group;
}
//
#endif	/* _VIEW_H */
